﻿using System;
using System.Collections.Generic;
using Microsoft.Practices.Unity;
using NHibernate;

namespace RG.Common.Provider
{
    // Для тестов!
    public class FakeSession : IDAOTransaction
    {
        [Dependency]
        public IUnityContainer ParentCfg { get; set; }

        public IList<T> List<T>(NHibernate.Criterion.ICriterion expr)
        {
            throw new NotImplementedException();
        }

        public IList<T> List<T>(NHibernate.Criterion.DetachedCriteria criteria)
        {
            return new List<T>();
        }

        public T Get<T>(object objId)
        {
            T ret = default(T);
            return ret;
        }

        public IQuery GetNamedQuery(string queryName)
        {
            throw new NotImplementedException();
        }

        public void Evict(object o)
        {
        }

        public void Refresh(object o)
        {
        }

        public void Dispose()
        {
        }

        public void Put(object Obj)
        {
        }

        public bool Contains(object obj)
        {
            throw new NotImplementedException();
        }

        public void Insert(object obj)
        {
            //throw new System.NotImplementedException();
        }

        public void Update(object obj)
        {
            throw new NotImplementedException();
        }

        public void Delete(object obj)
        {
            //throw new System.NotImplementedException();
        }

        public bool IsCommited { get; set; }

        public void Commit()
        {
            //пока убрали
            //if(IsCommited)
            //throw new System.Exception("Коммитим закомиченную транзакцию");
            //IsCommited = true;
        }

        public void RollBack()
        {
        }

        public void Flush()
        {
        }
    }
}